<template>
  <div class="wrapper">
    <div class="meun_item" @dragstart="dragstart" :data-type="item.type" :data-name="item.name" draggable="true" v-for="(item,index) in menus" :key="index">
      {{item.name}}
    </div>
  </div>
</template>

<script>
// 引入menus
import menus from '@/views/menu-list'
export default {
  name: 'VComList',
  data() {
    return {
      menus: menus
    }
  },
  methods: {
    // 拖拽开始事件
    dragstart(e) {
      // 获取数据
      const info = {
        name: e.target.getAttribute('data-name'),
        type: e.target.getAttribute('data-type'),
      }
      e.dataTransfer.setData('info', JSON.stringify(info))
    }
  },
  created() { },
  mounted() { }
}
</script>

<style lang="less" scoped>
.wrapper {
  width: 243px;
  padding: 8px;
  .meun_item {
    background: #eee;
    width: 100px;
    height: 100px;
    float: left;
    margin: 10px;
    text-align: center;
    line-height: 100px;
    cursor: pointer;
  }
}
</style>